//
//  IndexCell.m
//  UIScrollView的快速使用
//
//  Created by hongfei tam on 2018/12/27.
//  Copyright © 2018 YQ05. All rights reserved.
//

#import "IndexCell.h"
#import "Common/network/imgDownload/UIImageView+Cache.h"
#import "MKConstant.h"

@interface IndexCell ()

@property (nonatomic, strong) UIImageView *igv;
@property (nonatomic, strong) UILabel *lbTitle;
@property (nonatomic, strong) UILabel *lbSummar;

@end

@implementation IndexCell

- (void)setModel:(NSDictionary *)dict {
 
    self.lbTitle.text = dict[@"title"];
    
//    NSNumber *idstr = dict[@"detail"];  //ID
//    NSString *disid = [NSString stringWithFormat:@"%ld",(long)idstr.integerValue];
//    //NSLog(@"id = %d",idstr.integerValue);
//    self.lbSummar.text = disid;
    
    [self.igv mk_setImageWithUrl:dict[@"img"] placeHolder:[UIImage imageNamed:@"loadinggray.png"] complete:^(UIImage *image, BOOL cache) {
    }];
}


- (UIImageView *)igv {
    if (!_igv) {
        _igv = [[UIImageView alloc] initWithFrame:CGRectMake((UISCREEN_WIDTH - 300)/2, 50, 300, 300)];
        _igv.contentMode = UIViewContentModeScaleAspectFill;
        _igv.clipsToBounds = YES;
        [self.contentView addSubview:_igv];
    }
    return _igv;
}

- (UILabel *)lbTitle {
    if (!_lbTitle) {
//        _lbTitle = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.igv.frame) + 15, 5, [UIScreen mainScreen].bounds.size.width - CGRectGetMaxX(self.igv.frame) + 30 , 40)];
        _lbTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, (UISCREEN_WIDTH - 20*2 ) , 40)];
        _lbTitle.numberOfLines = 2;
        _lbTitle.font = [UIFont systemFontOfSize:18];
        _lbTitle.textAlignment = NSTextAlignmentCenter; //UITextAlignmentCenter 字體居中
        _lbTitle.textColor = MENUBROWN;
        [self.contentView addSubview:_lbTitle];
    }
    return _lbTitle;
}

- (UILabel *)lbSummar {
    if (!_lbSummar) {
        _lbSummar = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.igv.frame) + 15, CGRectGetMaxY(self.lbTitle.frame), [UIScreen mainScreen].bounds.size.width - CGRectGetMaxX(self.igv.frame) + 30 , 33)];
        _lbSummar.numberOfLines = 2;
        _lbSummar.font = [UIFont systemFontOfSize:13];
        _lbSummar.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_lbSummar];
    }
    return _lbSummar;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated { //cell 选中效果
    //[super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
